package org.jsbd.boss.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jsbd.boss.common.DataGridModel;
import org.jsbd.boss.dao.IBookCompanyDao;
import org.jsbd.boss.domian.BookCompany;
import org.jsbd.boss.service.IBookCompanyService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("bookCompanyService")
public class BookCompanyServiceImpl implements IBookCompanyService {

	@Autowired
	private IBookCompanyDao bookCompanyDao;

	@Override
	public void save(BookCompany bookCompany) {
		bookCompanyDao.save(bookCompany);
	}

	@Override
	public void save(List<BookCompany> list) {
		bookCompanyDao.save(list);
	}

	@Override
	public int update(BookCompany bookCompany) {
		return bookCompanyDao.update(bookCompany);
	}

	@Override
	public BookCompany get(BookCompany bookCompany) {
		return bookCompanyDao.get(bookCompany);
	}

	@Override
	public BookCompany getById(Integer id) {
		return bookCompanyDao.getById(id);
	}

	@Override
	public List<BookCompany> getList(BookCompany bookCompany){
		return bookCompanyDao.getList(bookCompany);
	}
	
	@Override
	public Map<String, Object> getListPage(DataGridModel page, BookCompany bookCompany) {
		
		bookCompany = (bookCompany == null ? new BookCompany() : bookCompany);
		bookCompany.setPageInfo(page);
		Map<String, Object> results = new HashMap<String, Object>();
		results.put("total", bookCompanyDao.getListPageCount(bookCompany));
		
		List<BookCompany> list = (List<BookCompany>) bookCompanyDao.getList(bookCompany);
		for (BookCompany bk : list) {
			bk.setCreateDate(org.jsbd.boss.util.DateUtil.getYmdhmsDateStr(bk.getCreateTime()));
			bk.setModifyDate(org.jsbd.boss.util.DateUtil.getYmdhmsDateStr(bk.getModifyTime()));
		}
		results.put("rows", list);
		return results;
	}
	
	@Override
	public void delete(List<Integer> ids) {
		bookCompanyDao.delete(ids);
	}

}
